#include <stdio.h>
#include <math.h>

int main(void) {
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf(" ");
        int score = 0;
        int coin_combo = 0;
        int c;
        while(c = getchar(), c != EOF && c != '#' && c != '\n') {
            if (c == 'O') {
                // 基础收益
                score += 20;
                switch (coin_combo) {
                    case 0:
                        break;
                    case 1:
                        score += 10;
                        break;
                    case 2:
                        score += 20;
                        break;
                    default:
                        score += 30;
                        break;
                }
                coin_combo++;
            } else {
                coin_combo = 0;
            }
        }
        printf("%d\n", score);
    }
    return 0;
}
